<?php

namespace app\admin\model\statistics;

use think\Model;
use traits\model\SoftDelete;

class Materialplan extends Model
{

//    use SoftDelete;



    // 表名
    protected $name = 'material_plan';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'attribute_text',
        'status_text'
    ];
    

    
    public function getAttributeList()
    {
        return ['0' => __('Attribute 0'), '1' => __('Attribute 1')];
    }

    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3')];
    }


    public function getAttributeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['attribute']) ? $data['attribute'] : '');
        $list = $this->getAttributeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function colour()
    {
        return $this->belongsTo('app\admin\model\Colour', 'colour_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function createuser()
    {
        return $this->belongsTo('app\admin\model\Admin', 'create_uid', 'id', [], 'LEFT')->setEagerlyType(0);
    }


}
